<script setup>
import { ref } from 'vue';
const messages = ref(
    [
        {
            id: 1,
            profileSrc: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/3364143/download+%281%29.png',
            username: 'Madison Jones',
            message: 'What time was our meet',
            date: '20m'
        },
        {
            id: 2,
            profileSrc: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/3364143/download+%2812%29.png',
            username: 'Jordan Smith',
            message: 'Snackwave craft beer raclette, beard kombucha',
            date: '2h'
        }
    ]
)

</script>

<template>
    <div class="conversation-area">
        <div class="msg online" v-for="msg in messages" :key="msg.id">
            <img class="msg-profile" :src="msg.profileSrc" alt="" />
            <div class="msg-detail">
                <div class="msg-username">{{ msg.username }}</div>
                <div class="msg-content">
                    <span class="msg-message">{{ msg.message }}</span>
                    <span class="msg-date">{{ msg.date }}</span>
                </div>
            </div>
        </div>
        <button class="add"></button>
        <div class="overlay"></div>
    </div>
</template>

<style lang="scss" scoped>
.conversation-area {
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.conversation-area,
.detail-area {
    width: 340px;
    flex-shrink: 0;
}

@media (max-width: 780px) {
    .conversation-area {
        display: none;
    }

    .search-bar {
        margin-left: 0;
        flex-grow: 1;

        input {
            padding-right: 10px;
        }
    }
}

.msg-profile {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;

    &.group {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: var(--border-color);

        svg {
            width: 60%;
        }
    }
}

.msg {
    display: flex;
    align-items: center;
    padding: 20px;
    cursor: pointer;
    transition: 0.2s;
    position: relative;

    &:hover {
        background-color: var(--msg-hover-bg);
    }

    &.active {
        background: var(--active-conversation-bg);
        border-left: 4px solid var(--theme-color);
    }

    &.online:before {
        content: "";
        position: absolute;
        background-color: #23be7e;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        border: 2px solid var(--theme-bg-color);
        left: 50px;
        bottom: 19px;
    }
}

.msg-username {
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 15px;
}

.msg-detail {
    overflow: hidden;
}

.msg-content {
    font-weight: 500;
    font-size: 13px;
    display: flex;
}

.msg-message {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--msg-message);
}

.msg-date {
    font-size: 14px;
    color: var(--msg-date);
    margin-left: 3px;

    &:before {
        content: "•";
        margin-right: 2px;
    }
}

.add {
    position: sticky;
    bottom: 25px;
    background-color: var(--theme-color);
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-plus'%3e%3cpath d='M12 5v14M5 12h14'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: 50%;
    background-size: 28px;
    box-shadow: 0 0 16px var(--theme-color);
    margin: auto auto -55px;
    flex-shrink: 0;
    z-index: 1;
    cursor: pointer;
}

.overlay {
    position: sticky;
    bottom: 0;
    left: 0;
    width: 340px;
    flex-shrink: 0;
    background: var(--overlay-bg);
    height: 80px;
}
</style>